home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / pluginWin.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  36.1 KB  |  1,319 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:   29 July 1996
  22. //
  23. //  Description:
  24. //      This implements the plugin-manager utility window
  25. //
  26. //  Procedures:
  27. //     pluginWin, updatePluginWin, browsePlugin, displayPluginInfo, 
  28. //     loadPluginCallback
  29. //
  30.  
  31. global int $pluginListSize = 0;
  32. global string $pluginNewestFile[];
  33. global int $pluginFileCount[];
  34. global string $defaultPluginBrowseDir = "";
  35.  
  36. /////////////////////////////////////////////////////////////////
  37. // Helper Functions: these are not exported to the application //
  38. /////////////////////////////////////////////////////////////////
  39.  
  40. proc string getDir( string $path ) 
  41. //
  42. //  Procedure Name:
  43. //      getDir
  44. //
  45. //  Description:
  46. //      strips the file name off of a path
  47. //
  48. //  Return Value:
  49. //      the directory name
  50. //    
  51. {
  52.     string $dir = match( "^.*/", $path );
  53.  
  54.     int $sz = size( $dir );
  55.     // Strip off trailing '/'
  56.     //
  57.     if ( ( $sz > 1 ) && ( substring( $dir, $sz, $sz ) == "/" ) ) {
  58.         $dir = substring( $dir, 1, ($sz - 1) );
  59.     } 
  60.     return $dir;
  61. }
  62.  
  63. proc string getFile( string $path ) 
  64. //
  65. //  Procedure Name:
  66. //      getFile
  67. //
  68. //  Description:
  69. //      returns the final file name in a path
  70. //
  71. //  Return Value:
  72. //      the file name
  73. //    
  74. {
  75.     string $file = match( "[^/]*$", $path );
  76.     return $file;
  77. }
  78.  
  79. proc string abbreviatePath( string $path, int $maxLen )
  80. //
  81. //  Procedure Name:
  82. //      abbreviatePath
  83. //
  84. //  Description:
  85. //      takes a path and trims out some of the middle if
  86. //      it is too long.  The middle part that is taken
  87. //      out will be replaced by "..."
  88. //
  89. {
  90.     int $len = size( $path );
  91.     if ( $maxLen < $len ) {
  92.         int $trimSize = ( $maxLen - 3 ) / 2;
  93.         string $newString = ( `substring $path 1 $trimSize` + "..." 
  94.             + `substring $path ( $len - $trimSize + 1 ) $len` );
  95.         return $newString;
  96.     }
  97.     return $path;                          
  98. }
  99.  
  100.  
  101. /////////////////////////////////////////////////////////////
  102. // Plugin List code.  Maintain a list of plugin info using //
  103. // the available single dimensional arrays in MEL          //
  104. /////////////////////////////////////////////////////////////
  105.  
  106. //
  107. //  Procedure Name:
  108. //      pluginListEntry
  109. //
  110. //  Description:
  111. //      gets info about the plugin at the given index
  112. //
  113. //  Return Value:
  114. //      the contents of the given field
  115. //
  116. proc string pluginListEntry( int $index, string $field ) 
  117. {
  118.     global string $pluginManagerList[];
  119.     int $numElements = 4;
  120.     
  121.     if ( $field == "path" ) {
  122.         $name = $pluginManagerList[$numElements * $index]; 
  123.         return $name;
  124.     } else if ( $field == "fileName" ) { 
  125.         $path = $pluginManagerList[$numElements * $index];
  126.         $name = getFile( $path );
  127.         return $name;
  128.     } else if ( $field == "loadedWidget" ) { 
  129.         $name = $pluginManagerList[($numElements * $index) + 1]; 
  130.         return $name;
  131.     } else if ( $field == "autoloadWidget" ) { 
  132.         $name = $pluginManagerList[($numElements * $index) + 2]; 
  133.         return $name;
  134.     } else if ( $field == "infoWidget" ) { 
  135.         $name = $pluginManagerList[($numElements * $index) + 3]; 
  136.         return $name;
  137.     }
  138.     return "";
  139. }
  140.  
  141.  
  142. proc setPluginListEntry( int $index, string $path, string $loadedWiget,
  143.                          string $autoWidget, string $infoWidget )
  144. //
  145. //  Procedure Name:
  146. //      setPluginListEntry
  147. //
  148. //  Description:
  149. //      Set information about the plugin at the given index
  150. //
  151. //  Return Value:
  152. //      none
  153. //    
  154. {
  155.     global string $pluginManagerList[];
  156.     int $numElements = 4;
  157.     
  158.     $pluginManagerList[$numElements * $index] = $path;
  159.     $pluginManagerList[($numElements * $index) + 1] = $loadedWiget;
  160.     $pluginManagerList[($numElements * $index) + 2] = $autoWidget;
  161.     $pluginManagerList[($numElements * $index) + 3] = $infoWidget;
  162. }
  163.  
  164. proc int appendPluginListEntry( string $path, string $loadedWiget,
  165.                                 string $autoWidget, string $infoWidget )
  166. //
  167. //  Procedure Name:
  168. //      appendPluginListEntry
  169. //
  170. //  Description:
  171. //      appends an item to the list of plugins in the UI
  172. //
  173. //  Return Value:
  174. //      in index in the list of the new item
  175. //
  176. {
  177.     global int $pluginListSize;
  178.     int $i = $pluginListSize;
  179.     setPluginListEntry( $i, $path, $loadedWiget, $autoWidget, $infoWidget );
  180.     $pluginListSize++;
  181.     return $i;
  182. }
  183.  
  184. proc int removePluginListEntries (string $path)
  185. //
  186. //  Procedure Name:
  187. //      removePluginListEntries
  188. //
  189. //  Description:
  190. //      Remove all entries associated in the directory given by $path
  191. //
  192. {
  193.     global string $pluginManagerList[];
  194.     global int $pluginListSize;
  195.     int $numElements = 4;
  196.     
  197.     int $i, $j;
  198.     int $numRemoved = 0;
  199.  
  200.     for ($i = 0; $i < $pluginListSize; $i++)
  201.         if (getDir (pluginListEntry ($i, "path")) == $path)
  202.             $numRemoved++;
  203.         else if ($numRemoved != 0)
  204.             for ($j = 0; $j < $numElements; $j++)
  205.                 $pluginManagerList[($i - $numRemoved) * $numElements + $j] =
  206.                     $pluginManagerList[$i * $numElements + $j];
  207.     $pluginListSize -= $numRemoved;
  208.     return $numRemoved;
  209. }
  210.  
  211. proc int isPathInSearchPath( string $path ) 
  212. //
  213. //  Procedure Name:
  214. //      isPathInSearchPath
  215. //
  216. //  Description:
  217. //      determines if the given path is in our plugin search path
  218. //
  219. //  Return Value:
  220. //      whether it is in the path
  221. //
  222. {
  223.     global string $verifiedPluginPath[];
  224.     for ($nextPath in $verifiedPluginPath) {
  225.         if ( $path == $nextPath ) {
  226.             return true;
  227.         }
  228.     }
  229.     return false;
  230. }
  231.  
  232. proc int isPluginInUI( string $path ) 
  233. //
  234. //  Procedure Name:
  235. //      isPluginInUI
  236. //
  237. //  Description:
  238. //      determines if the given plugin is listed in our UI already
  239. //
  240. //  Return Value:
  241. //      whether it is in the UI
  242. //
  243. {
  244.     global int $pluginListSize;
  245.     string $name = `pluginInfo -query -name $path`;
  246.  
  247.     for ($i = 0; $i < $pluginListSize; ++$i) {
  248.         string $plugPath = pluginListEntry( $i, "path" );
  249.         if ( `pluginInfo -query -registered $plugPath` ) {
  250.             string $plugName = `pluginInfo -query -name $plugPath`;
  251.             if ( $name == $plugName ) {
  252.                 return true;
  253.             }
  254.         }
  255.     }
  256.     return false;
  257. }
  258.  
  259. proc addSinglePlugin( string $path, string $parent )
  260. //
  261. //  Procedure Name:
  262. //      addSinglePlugin
  263. //
  264. //  Description:
  265. //      adds a single plugin, creating the widgets
  266. //
  267.     // Make sure the path is using forward slashes regardless of the platform
  268.     $path = convert($path);
  269.     setParent $parent; 
  270.     string $name = getFile( $path );
  271.  
  272.     int $i = appendPluginListEntry( $path, "", "", "" );
  273. //    rowLayout -nc 4 -cl1 "left"
  274. //        -columnWidth4 125 70 105 25
  275. //        -adjustableColumn 1
  276. //        -columnAlign 4 "center";
  277.     text -l $name ("PlugNameTxt" + (string)$i);
  278.     string $loadedCheck = `checkBox -align "left" -l "loaded" 
  279.         ("plugLoadedChk" + (string)$i)`; 
  280.     string $autoBox = `checkBox -align "left" -l "auto load" 
  281.         ("plugAutoLoadChk" + (string)$i)`;
  282.     string $symButt = `symbolButton -image "info.xpm" ("plugInfoBtn" + (string)$i)`;
  283. //    string $symButt = `symbolButton -image "info.xpm" -width 25 -height 28
  284. //        ("plugInfoBtn" + (string)$i)`;
  285.  
  286.     // Store the widget name so that we can update this widget later
  287.     //
  288.     setPluginListEntry( $i, $path, $loadedCheck, $autoBox, $symButt );
  289.  
  290.     // Add callbacks to controls
  291.     //
  292.     checkBox -edit -onCommand ("waitCursor -state on; catch( `loadPlugin \""
  293.         + $path + "\"`); waitCursor -state off;") 
  294.         -offCommand  ( "unloadPluginWithCheck( \"" + $path + "\" );" ) $loadedCheck;
  295.     checkBox -edit -onCommand ("pluginInfo -edit -autoload true \""
  296.         + $path + "\";" ) -offCommand 
  297.         ("pluginInfo -edit -autoload false \"" + $path + "\";" ) $autoBox;
  298.     symbolButton -edit -command ("displayPluginInfo \"" + $path + "\";" ) $symButt; 
  299. }
  300.  
  301. proc addDirectory( string $dirName, string $parent, int $index )
  302. //
  303. //  Procedure Name:
  304. //      addDirectory
  305. //
  306. //  Description:
  307. //      adds a new directory, creating the layout widget
  308. //
  309. {
  310.     global string $pluginNewestFile[];
  311.     global int $pluginFileCount[];
  312.  
  313.     string $tempString[];
  314.  
  315.     // Create a new layout widget
  316.     //
  317.     setParent $parent;
  318.     string $dir = getFile( getDir( $dirName ) ); 
  319.  
  320.     string $frameName = "PluginFrameLyt" + (string)$index;
  321.     string $par;
  322. //    string $colName = "PluginColLyt" + (string)$index;
  323.     if (`frameLayout -exists $frameName`) {
  324. //        setParent $colName;
  325.         setParent $frameName;
  326.     } else {
  327.         string $labelStr;
  328.         $labelStr = $dirName;
  329. //        $labelStr = abbreviatePath( $dirName, 50 );
  330.         frameLayout 
  331.             -mw 10 -mh 10
  332.             -borderStyle "etchedIn"
  333.             -borderVisible true 
  334.             -collapse false -collapsable true
  335.             -label $labelStr -labelVisible true $frameName;
  336. //        columnLayout -adjustableColumn true $colName;
  337.     }
  338.     string $rowColName = "PluginRowColLyt" + (string)$index;
  339.     if(`about -mac`)
  340.     {
  341.         $par = `rowColumnLayout  -cat 1 "left" 2 -columnWidth 1 200
  342.             -columnWidth 2 70
  343.             -columnWidth 3 105 -columnWidth 4 25 -nc 4 $rowColName`;
  344.     } else {
  345.         $par = `rowColumnLayout -cal 1 "left" -columnWidth 1 125
  346.             -columnWidth 2 70
  347.             -columnWidth 3 105 -columnWidth 4 25 -nc 4 $rowColName`; 
  348.     }
  349.  
  350.     // Read the directory, retaining a file count
  351.     //
  352.     string $dirList[];
  353.     string $pattern = "*.so";
  354.     if ( `about -windows` ) {
  355.         $pattern = "*.mll";
  356.     }else if( `about -mac` ){
  357.         $pattern = "*.lib";
  358.     }
  359.     
  360.     if( `about -mac` ){
  361.         catch( $dirList = `getFileList -folder $dirName -filespec $pattern` );
  362.     }else { 
  363.         catch( $dirList = `getFileList -folder ( $dirName + "/" ) -filespec $pattern` );
  364.     }
  365.  
  366.     int $fileCount = size( $dirList );
  367.     for ( $fileName in $dirList ) {
  368.         string $path = $dirName + "/" + $fileName;
  369.         addSinglePlugin( $path, $par );
  370.     }
  371.  
  372.     int $file;
  373.     // Now find the name of the newest file for later rescans
  374.     if (`about -nt`) {
  375.         $tempString = `getFileList  -folder ($dirName + "/") -filespec "*.mll"`;
  376.     }
  377.     else if(`about -mac`) {
  378.         $tempString = `getFileList  -folder $dirName -filespec "*.lib"`;
  379.     } else {
  380.         $file = popen( ( "ls -1t \"" + $dirName + "\"/*.so 2> /dev/null" ), "r" ); 
  381.     }
  382.     //string $plug = fgetline ($file);
  383.     string $plug ;
  384.     if(`about -mac` || `about -nt`) {
  385.         if(size($tempString) == 0){
  386.             $plug = 0;
  387.         }else{
  388.             $plug = $tempString[size($tempString) -1];
  389.         }
  390.     } else {
  391.         $plug = fgetline ($file);
  392.     }
  393.     
  394.     // Strip the newline
  395.     $plug = strip( $plug );
  396.  
  397.     if (`about -nt` || `about -mac`) {
  398.          $pluginNewestFile [$index] = $dirName + "/" + $plug;
  399.     }
  400.     else {
  401.         $pluginNewestFile [$index] = $plug;
  402.     }
  403.  
  404.     if(`about -nt` || `about -irix` || `about -linux`) {
  405.         pclose $file;
  406.     }
  407.     $pluginFileCount[$index] = $fileCount;
  408.  
  409. proc resetGlobals ()
  410. //
  411. //  Procedure Name:
  412. //      resetGlobals
  413. //
  414. //  Description:
  415. //      Resets the plug-in manager for a fresh start. This should only be
  416. //      done if the UI is already deleted.
  417. //
  418. //  Return Value:
  419. //      the directory name
  420. //    
  421. {
  422.     global string $verifiedPluginPath[];
  423.     global int    $isPluginPathVerified;
  424.     global string $pluginWinParentWidget;
  425.     global string $pluginWinSingleParent;
  426.     global string $pluginWindowName;
  427.     global int    $pluginListSize;
  428.     global string $pluginManagerList[];
  429.     global string $pluginNewestFile[];
  430.     global int    $pluginFileCount[];
  431.  
  432.     clear $verifiedPluginPath;
  433.     $isPluginPathVerified = false;
  434.     $pluginListSize = 0;
  435.     clear $pluginManagerList;
  436.     clear $pluginNewestFile;
  437.     clear $pluginFileCount;
  438. }
  439.  
  440. proc int dirChanged (string $dirName, int $index)
  441. //
  442. //  Procedure Name:
  443. //      dirChanged
  444. //
  445. //  Description:
  446. //      Determines whether or not $dirName has changed and needs to be
  447. //      re-scanned.
  448. //
  449. //  Return Value:
  450. //      the directory name
  451. //    
  452. {
  453.     global string $pluginNewestFile[];
  454.     global int $pluginFileCount[];
  455.     string $fileList[];
  456.  
  457.     // Retrieve a list of files, sorted by date
  458.     int $file;
  459.     if (`about -nt`) {
  460.         $fileList = `getFileList  -folder ($dirName + "/") -filespec "*.mll"`;
  461.     }
  462.     else if(`about -mac`) {
  463.         $fileList = `getFileList  -folder $dirName -filespec "*.lib"`;
  464.     } else {
  465.         $file = popen( ( "ls -1t \"" + $dirName + "\"/*.so 2> /dev/null" ), "r" ); 
  466.     }
  467.  
  468.     // Retrieve the first file
  469.     //string $plug = fgetline( $file );
  470.     string $plug ;
  471.     if(`about -mac` || `about -nt`) {
  472.         $plug = $fileList[0];
  473.     } else {
  474.         $plug = fgetline( $file );
  475.     }
  476.     
  477.     // Strip the newline
  478.     $plug = strip( $plug );
  479.  
  480.     if ( `about -nt` || `about -mac` )
  481.         $plug = $dirName + "/" + $plug;
  482.  
  483.     // Now count the number of files - a double check
  484.     int $count = 0;
  485.     int $isDirty = 0;
  486.     
  487.     if (`about -mac` || `about -nt` ) {
  488.         string  $singleFile;
  489.         for ($singleFile in $fileList) {
  490.             if(size($singleFile) > 1){
  491.                 $count++;
  492.                 $plug = $dirName + "/" + $singleFile;
  493.                 
  494.                 // Check if every plugin is present in the pluginListEntry
  495.                 // If not set the dirty flag so that the list is regenerated
  496.                 
  497.                 global int    $pluginListSize;
  498.                 int $fileExists = 0;
  499.                 for ($i = 0; $i < $pluginListSize; $i++)
  500.                 {
  501.                     string $fileEntry = pluginListEntry ($i, "path");
  502.                     if ($plug == $fileEntry) {
  503.                         $fileExists = 1;
  504.                         break;
  505.                     }
  506.                 }
  507.  
  508.                 if ($fileExists == 0) {
  509.                     $isDirty = 1;
  510.                     break;
  511.                 }
  512.             }
  513.         }
  514.     } else {
  515.         string $line = $plug;
  516.  
  517.         while (size($line) > 1)
  518.         {
  519.             $count++;
  520.             $line = fgetline ( $file);
  521.         }
  522.         pclose $file;
  523.  
  524.         // $plug now contains the newest file in the directory. If this file
  525.         // doesn't match the newest from the last time around or the file count
  526.         // doesn't match, the directory has changed and needs to be regenerated.
  527.         // This is not the best solution to the problem, but until MEL gets a
  528.         // stat() method, it's the only way...
  529.         
  530.         if ($plug != $pluginNewestFile [$index])
  531.             $isDirty = 1;
  532.     }
  533.  
  534.     if ($count == $pluginFileCount [$index] &&
  535.          $isDirty == 0)
  536.         return false;
  537.     return true;
  538. }
  539.  
  540. proc rescanDirectory( string $dirName, string $parent, int $index)
  541. //
  542. //  Procedure Name:
  543. //      rescanDirectory
  544. //
  545. //  Description:
  546. //      rescans a directory, creating layout widgets for any new plug-ins and
  547. //      removing layout widgets for removed plug-ins
  548. {
  549.     if (dirChanged ($dirName, $index)) {
  550.         string $frame = "PluginFrameLyt" + (string) $index;
  551.         string $children[] = `frameLayout -q -childArray $frame`;
  552. //        string $par = "PluginColLyt" + (string) $index;
  553. //        string $children[] = `columnLayout -q -childArray $par`;
  554.  
  555.         string $child;
  556.  
  557.         for ($child in $children)
  558.             deleteUI $child;
  559.         removePluginListEntries ($dirName);
  560.         addDirectory ($dirName, $parent, $index);
  561.     }    
  562. }
  563.  
  564. //////////////////////
  565. // Global Functions //
  566. //////////////////////
  567.  
  568. global proc updatePluginWin()
  569. //
  570. //  Procedure Name:
  571. //      updatePluginWin
  572. //
  573. //  Description:
  574. //      refreshes the values in the plugin window 
  575. //
  576. //  Return Value:
  577. //      None
  578. //
  579. {
  580.     global string $verifiedPluginPath[];
  581.     global int    $isPluginPathVerified;
  582.     global string $pluginWinParentWidget;
  583.     global string $pluginWinSingleParent;
  584.     global string $pluginWindowName;
  585.     global int    $pluginListSize;
  586.  
  587.     // Make sure the window exists
  588.     //
  589.     if (!`window -exists $pluginWindowName`) {
  590.         return;
  591.     }
  592.  
  593.     int $buildUI = false;
  594.  
  595.  
  596.     // Make sure that our path array is set up
  597.     //
  598.     if ( !$isPluginPathVerified ) {
  599.         // We will read the environment variable and check to see that all paths
  600.         // are valid
  601.         //
  602.         string $pathEnvVar = getenv("MAYA_PLUG_IN_PATH");
  603.  
  604.         string $pathArray[];
  605.         if (`about -nt` || `about -mac`) {
  606.             tokenize( $pathEnvVar, ";", $pathArray );
  607.         }
  608.         else {
  609.             tokenize( $pathEnvVar, ":", $pathArray );
  610.         }
  611.         
  612.         // Check that the paths are valid
  613.         //
  614.         int $index = 0;
  615.         for ($path in $pathArray) {
  616.             string $oldPath = `pwd`;
  617.             // Expand the environment variables in the path
  618.             //
  619.             string $expandedPath;
  620.             if (`about -nt` || `about -mac`) {
  621.                 $expandedPath = $path;
  622.             }
  623.             else {
  624.                 $expandedPath = system( "echo " + $path );
  625.                 // Strip the newline
  626.                 $expandedPath = strip ($expandedPath);
  627.             }
  628.             if ( 0 == `chdir $expandedPath` ) {
  629.                 // Get the expanded path in standard form
  630.                 //
  631.                 if(`about -mac`) {
  632.                     $verifiedPluginPath[$index] = $expandedPath;
  633.                 } else {
  634.                     $verifiedPluginPath[$index] =`pwd`;
  635.                 }
  636.                 chdir $oldPath;
  637.                  ++$index;
  638.             }
  639.         } 
  640.         $buildUI = true;
  641.         $isPluginPathVerified = 1;
  642.     } 
  643.  
  644.     if ( $buildUI ) { 
  645.         // The UI hasn't been built yet
  646.         //
  647.         waitCursor -state on;
  648.  
  649.         int $index = 1;
  650.         for ( $path in $verifiedPluginPath ) {
  651.             addDirectory( $path, $pluginWinParentWidget, $index );
  652.             $index++;
  653.         }
  654.         // Put in the misc section
  655.         //
  656.         setParent $pluginWinParentWidget;
  657.         frameLayout 
  658.             -borderStyle "etchedIn"
  659.             -borderVisible true -collapse false -collapsable true 
  660.             -label "Other Registered Plugins" -labelVisible true
  661.             -mw 10 -mh 10
  662.             "PluginFrameLytMisc";
  663.         if(`about -mac`) {
  664.             $pluginWinSingleParent = `rowColumnLayout  -cat 1 "left" 2 -columnWidth 1 200 
  665.                 -columnWidth 2 70 -columnWidth 3 105 -columnWidth 4 25 -nc 4
  666.                 PluginRowColLytMisc`;
  667.         } else {
  668.             $pluginWinSingleParent = `rowColumnLayout -cal 1 "left" -columnWidth 1 125 
  669.                 -columnWidth 2 70 -columnWidth 3 105 -columnWidth 4 25 -nc 4
  670.                 PluginRowColLytMisc`;
  671.         }
  672. //        $pluginWinSingleParent = `columnLayout -adjustableColumn true
  673. //          PluginColLytMisc`;
  674.  
  675.         waitCursor -state off;
  676.     } 
  677.     else {
  678.         int $index = 1;
  679.         for ( $path in $verifiedPluginPath ) {
  680.             rescanDirectory( $path, $pluginWinParentWidget, $index );
  681.             $index++;
  682.         }
  683.     }
  684.  
  685.     // Make sure that all registered plugins appear in UI
  686.     // 
  687.     string $knownPlugins[] = `pluginInfo -q -listPlugins`;
  688.  
  689.     string $dir; 
  690.     for ( $plugin in $knownPlugins ) {  
  691.         $path = `pluginInfo -query -path $plugin`;
  692.         $dir = getDir( $path );
  693.         if ( !isPathInSearchPath( $dir ) ) {
  694.             // We don't know this path, so this is a singleton plugin
  695.             //
  696.             if ( !isPluginInUI( $plugin ) ) {
  697.                 addSinglePlugin( $path, $pluginWinSingleParent );
  698.             }
  699.         }
  700.     }
  701.  
  702.     // Now, we need to make sure that the check boxes in the UI reflect the current
  703.     // state
  704.     //
  705.     for ($i=0; $i < $pluginListSize; ++$i) {
  706.         string $path = pluginListEntry( $i, "path" );
  707.         string $loadedWidgName = pluginListEntry( $i, "loadedWidget" );
  708.         string $autoWidgName = pluginListEntry( $i, "autoloadWidget" );
  709.         string $infoWidgName = pluginListEntry( $i, "infoWidget" );
  710.  
  711.         int $isLoaded = `pluginInfo -query -loaded $path`; 
  712.  
  713.         if ( $isLoaded != ( `checkBox -query -value $loadedWidgName` ) ) {
  714.             checkBox -edit -value $isLoaded $loadedWidgName;
  715.         }             
  716.         // Check autoload status
  717.         //
  718.         int $auto = `pluginInfo -query -autoload $path`;
  719.         checkBox -edit -value $auto $autoWidgName;
  720.  
  721.          if ( `pluginInfo -query -registered $path` ) { 
  722.             // We have valid info for the plugin
  723.             // 
  724.             symbolButton -edit -enable 1 $infoWidgName; 
  725.         } else { 
  726.             // We don't have information about the given plugin in our database
  727.             // as it has never been loaded.  Therefore, we will dim the info button
  728.             // 
  729.             symbolButton -edit -enable 0 $infoWidgName;
  730.         }
  731.     }
  732.  
  733. global proc int loadPluginCallback( string $theFile, string $fileType )
  734. //
  735. //  Procedure Name:
  736. //      loadPluginCallback
  737. //
  738. //  Description:
  739. //      this is used by the file browser for actually loading the plugin, and
  740. //      also remembers the last directory from which a plug-in was loaded.
  741. //
  742. //  Return Value:
  743. //      None
  744. //    
  745. {
  746.     global string $defaultPluginBrowseDir;
  747.     $defaultPluginBrowseDir = `getDir $theFile`;
  748.     // Set the file rule - this makes sure that future calls to browse
  749.     // start from the same place
  750.     if ( catch( `loadPlugin $theFile` ) ) {
  751.          warning ( "Could not load " + $theFile + " as a plug-in" );
  752.          return false;
  753.      } 
  754.     return true;
  755. }
  756.  
  757. global proc browsePlugin() 
  758. //
  759. //  Procedure Name:
  760. //      browsePlugin
  761. //
  762. //  Description:
  763. //      this is a UI equivalent to loadPlugin.  It puts up a file requestor. 
  764. //      It keeps track of the directory it used last and maintains it
  765. //      separately from the workspace directory. It starts in the user's home
  766. //      directory.
  767. //
  768. //  Return Value:
  769. //      None
  770. //    
  771. {  
  772.     global string $defaultPluginBrowseDir;
  773.     global string $gDefaultFileBrowserDir;
  774.  
  775.     // Note: every time Maya is restarted, the file rule is reset. This is
  776.     // intentional - the default location is Maya's starting point. Change
  777.     // this if the default changes.
  778.     if ($defaultPluginBrowseDir == "") {
  779.             global string $verifiedPluginPath[];
  780.             if (size ($verifiedPluginPath) > 0)
  781.                 $defaultPluginBrowseDir =  $verifiedPluginPath[0];
  782.             else
  783.                 $defaultPluginBrowseDir =  pwd ();
  784.     }
  785.     $gDefaultFileBrowserDir = $defaultPluginBrowseDir;
  786.  
  787.     string $prevDir = `workspace -query -directory`;
  788.     workspace -directory $defaultPluginBrowseDir;
  789.     fileBrowser ( "loadPluginCallback", "Load Plug-in", "plug-in", 0 );
  790.     workspace -directory $prevDir;
  791. }
  792.  
  793. global proc displayPluginInfo( string $path ) 
  794. //
  795. //  Procedure Name:
  796. //      displayPluginInfo
  797. //
  798. //  Description:
  799. //      opens a window and displays information about the given plugin
  800. //
  801. //  Return Value:
  802. //      None
  803. //
  804. {
  805.     global string $pluginInfoWinName;
  806.     global string $pluginInfoWinPath;
  807.     global string $pluginInfoWinVendor;
  808.     global string $pluginInfoWinAutoLoad;
  809.     global string $pluginInfoWinLoaded;
  810.     global string $pluginInfoWinAPIVerson;
  811.     global string $pluginInfoWinVerson;
  812.     global string $pluginInfoWinFeatures; 
  813.     int    $numHtCount = 0;
  814.  
  815.     string $name = `pluginInfo -query -name $path`;
  816.     if ( catch( $path = `pluginInfo -query -path $name` ) ) {
  817.         warning "Plug-in information not in database";
  818.     }
  819.  
  820.     string $winName = "PluginInfoWin";
  821.  
  822.     if (!`window -exists $winName`) {
  823.         window -t "Plug-in Information"  -wh 340 280 $winName;
  824.         formLayout windowLyt;
  825.             scrollLayout -cr true scrollLayout;
  826.                 formLayout scrollWindowLyt; 
  827.                     columnLayout -adjustableColumn true infoLyt;
  828.                         rowLayout -nc 2 -cw2 100 340 -adjustableColumn 2;
  829.                         text -label "Name: " -align "left" nameTxt;
  830.                         $pluginInfoWinName = `text -align "left" nameValTxt`;
  831.                         setParent ..;
  832.  
  833.                         rowLayout -nc 2 -cw2 100 340 -adjustableColumn 2;
  834.                         text -label "Path: " -align "left" pathTxt;
  835.                         $pluginInfoWinPath = `text -align "left" pathValTxt`;
  836.                         setParent ..;
  837.  
  838.                         rowLayout -nc 2 -cw2 100 340 -adjustableColumn 2;
  839.                         text -label "Vendor: " -align "left" vendTxt; 
  840.                         $pluginInfoWinVendor = `text -align "left" vendValTxt`;
  841.                         setParent ..;
  842.  
  843.                         rowLayout -nc 2 -cw2 100 340 -adjustableColumn 2;
  844.                         text -label "Plug-in Version: " -align "left" versionTxt; 
  845.                         $pluginInfoWinVerson = `text -align "left" versValTxt`;
  846.                         setParent ..;
  847.  
  848.                         rowLayout -nc 2 -cw2 100 340 -adjustableColumn 2;
  849.                         text -label "For API Version: " -align "left" apiVersionTxt; 
  850.                         $pluginInfoWinAPIVerson = `text -align "left" apiVersValTxt`;
  851.                         setParent ..;
  852.  
  853.                         rowLayout -nc 2 -cw2 100 340 -adjustableColumn 2;
  854.                         text -label "Auto Load: " -align "left" autoTxt; 
  855.                         $pluginInfoWinAutoLoad = `text -align "left" autoValTxt`; 
  856.                         setParent ..;
  857.  
  858.                         rowLayout -nc 2 -cw2 100 340 -adjustableColumn 2;
  859.                         text -label "Is Loaded: " -align "left" isLoadedTxt; 
  860.                         $pluginInfoWinLoaded = `text -align "left" isLoadedValTxt`; 
  861.                         setParent ..;
  862.                     setParent ..;
  863.             
  864.                     frameLayout -borderVisible true
  865.                         -collapsable false -label "Plug-in Features" 
  866.                         -labelVisible true pluginFeaturesLyt;
  867.                         if(`about -mac`) {
  868.                             $pluginInfoWinFeatures = `textField  featuresTxt`;
  869.                         } else {
  870.                             $pluginInfoWinFeatures = `text -align "left" featuresTxt`; 
  871.                         }
  872.                     setParent ..;
  873.  
  874.                 formLayout -e    -af infoLyt "left" 0
  875.                                 -af infoLyt "right" 0 
  876.                                 -af infoLyt "top" 0
  877.                                 scrollWindowLyt; 
  878.  
  879.                 formLayout -e    -af pluginFeaturesLyt "left" 0 
  880.                                 -af pluginFeaturesLyt "right" 0
  881.                                 -af pluginFeaturesLyt "bottom" 0 
  882.                                 -ac infoLyt "bottom" 0 pluginFeaturesLyt
  883.                                 scrollWindowLyt;  
  884.                 setParent ..;
  885.             setParent ..;
  886.  
  887.         $closeInfoBtn = `button -l "Close" closeInfoBtn`;
  888.  
  889.         formLayout -e -af $closeInfoBtn "left" 5
  890.                       -af $closeInfoBtn "right" 5
  891.                       -af $closeInfoBtn "bottom" 5
  892.                       -an $closeInfoBtn "top"
  893.                       windowLyt;
  894.  
  895.         formLayout -e -af scrollLayout "top" 0
  896.                       -af scrollLayout "left" 0
  897.                       -af scrollLayout "right" 0
  898.                       -ac scrollLayout "bottom" 5 $closeInfoBtn
  899.                       windowLyt;
  900.  
  901.         button -edit -command "deleteUI PluginInfoWin" $closeInfoBtn;
  902.  
  903.         setParent ..; // close the formLayout
  904.     }  
  905.  
  906.     // Update all of the fields
  907.     //
  908.     text -edit -label $name $pluginInfoWinName;
  909.     text -edit -label $path $pluginInfoWinPath;
  910.     text -edit -label `pluginInfo -query -vendor $name` $pluginInfoWinVendor;
  911.     text -edit -label `pluginInfo -query -version $name` $pluginInfoWinVerson;
  912.     text -edit -label `pluginInfo -query -apiVersion $name` $pluginInfoWinAPIVerson;
  913.     if ( `pluginInfo -query -autoload $name` ) {
  914.         text -edit -label "Yes" $pluginInfoWinAutoLoad;
  915.     } else {
  916.         text -edit -label "No" $pluginInfoWinAutoLoad; 
  917.     } 
  918.     if ( `pluginInfo -query -loaded $name` ) {
  919.         text -edit -label "Yes" $pluginInfoWinLoaded;
  920.     } else {
  921.         text -edit -label "No" $pluginInfoWinLoaded; 
  922.     } 
  923.  
  924.     if(`about -mac`){
  925.         $numHtCount += 1;
  926.     }
  927.     // Build list of plugin features starting with commands
  928.     //
  929.     string $featureStr = "";
  930.     string $commands[] = `pluginInfo -query -command $name`;
  931.     if ( size( $commands ) > 0 ) {
  932.         $featureStr = "  Commands:\n";
  933.         if(`about -mac`) {
  934.             $numHtCount += 1; 
  935.         }
  936.         if(`about -mac`) {
  937.             $numHtCount += size( $commands );
  938.         }        
  939.         for ( $command in $commands ) {
  940.             $featureStr = ( $featureStr + "      " + $command ); 
  941.             if ( $command != $commands[ size( $commands ) - 1 ] ) {
  942.                 $featureStr = $featureStr + "\n";
  943.             }
  944.         } 
  945.     }
  946.  
  947.     // Build list of context commands
  948.     //
  949.     string $tools[] = `pluginInfo -query -tool $name`; 
  950.     if ( size( $tools ) > 0 ) {
  951.         if ( $featureStr != "" ) {
  952.             $featureStr = $featureStr + "\n\n";
  953.             if(`about -mac`){
  954.                     $numHtCount += 2;
  955.             }
  956.         } 
  957.         $featureStr = $featureStr + "  Tools:\n";
  958.         if(`about -mac`) {
  959.                     $numHtCount += 1;
  960.         }
  961.         if(`about -mac`) {
  962.             $numHtCount += size( $tools );
  963.         }    
  964.         for ( $tool in $tools ) {
  965.             $featureStr = ( $featureStr + "      " + $tool );  
  966.             if ( $tool != $tools[ size( $tools ) - 1 ] ) {
  967.                 $featureStr = $featureStr + "\n";
  968.             }
  969.         }
  970.     } 
  971.  
  972.     // Build list of dependency nodes
  973.     //
  974.     string $nodes[] = `pluginInfo -query -dependNode $name`;
  975.     if ( size( $nodes ) > 0 ) { 
  976.         if ( $featureStr != "" ) {
  977.             $featureStr = $featureStr + "\n\n";
  978.             if(`about -mac`) {
  979.                     $numHtCount += 2;
  980.             }
  981.         } 
  982.         $featureStr = $featureStr + "  Dependency Nodes:\n";
  983.         if(`about -mac`){
  984.             $numHtCount += 1;
  985.         }
  986.         if(`about -mac`) {
  987.             $numHtCount += size( $nodes );
  988.         }
  989.         for ( $node in $nodes ) {
  990.             $featureStr = ( $featureStr + "      " + $node );  
  991.             if ( $node != $nodes[ size( $nodes ) - 1 ] ) {
  992.                 $featureStr = $featureStr + "\n";
  993.             }
  994.         }
  995.     } 
  996.  
  997.     // Build list of dependency graph data types
  998.     //
  999.     string $data[] = `pluginInfo -query -data $name`; 
  1000.     if ( size( $data ) > 0 ) { 
  1001.         if ( $featureStr != "" ) {
  1002.             $featureStr = $featureStr + "\n\n";
  1003.             if(`about -mac`) {
  1004.                 $numHtCount += 2;
  1005.             }
  1006.         } 
  1007.         $featureStr = $featureStr + "  Dependency Graph Data Types:\n";
  1008.         if(`about -mac`) {
  1009.             $numHtCount += 1;
  1010.         }
  1011.         if(`about -mac`) {
  1012.             $numHtCount += size( $data );
  1013.         }    
  1014.         for ( $datum in $data ) {
  1015.             $featureStr = ( $featureStr + "      " + $datum );  
  1016.             if ( $datum != $data[ size( $data ) - 1 ] ) {
  1017.                 $featureStr = $featureStr + "\n";
  1018.             }
  1019.         }
  1020.     }
  1021.  
  1022.     // Build list of file translators
  1023.     //
  1024.     string $translators[] = `pluginInfo -query -translator $name`;
  1025.     if ( size( $translators ) > 0 ) {
  1026.         if ( $featureStr != "" ) {
  1027.             $featureStr = $featureStr + "\n\n";
  1028.             if(`about -mac`) {
  1029.                 $numHtCount += 2;
  1030.             }
  1031.         }
  1032.         $featureStr = $featureStr + "  File Translators:\n";
  1033.         if(`about -mac`) {
  1034.             $numHtCount += 1;
  1035.         }
  1036.         if(`about -mac`) {
  1037.             $numHtCount += size( $translators );
  1038.         }    
  1039.         for ( $translator in $translators ) {
  1040.             $featureStr = ( $featureStr + "      " + $translator );
  1041.             if ( $translator != $translators[ size( $translators ) - 1 ] ) {
  1042.                 $featureStr = $featureStr + "\n";
  1043.             }
  1044.         }
  1045.     }
  1046.  
  1047.     // Build list of ik solvers
  1048.     //
  1049.     string $ikSolvers[] = `pluginInfo -query -iksolver $name`;
  1050.     if ( size( $ikSolvers ) > 0 ) {
  1051.         if ( $featureStr != "" ) {
  1052.             $featureStr = $featureStr + "\n\n";
  1053.             if(`about -mac`){
  1054.                     $numHtCount += 2;
  1055.             }
  1056.         }
  1057.         $featureStr = $featureStr + "  Ik Solvers:\n";
  1058.         if(`about -mac`){
  1059.                     $numHtCount += 1;
  1060.         }
  1061.         if(`about -mac`)
  1062.             $numHtCount += size( $ikSolvers );
  1063.             
  1064.         for ( $ikSolver in $ikSolvers ) {
  1065.             $featureStr = ( $featureStr + "      " + $ikSolver );
  1066.             if ( $ikSolver != $ikSolvers[ size( $ikSolvers ) - 1 ] ) {
  1067.                 $featureStr = $featureStr + "\n";
  1068.             }
  1069.         }
  1070.     }
  1071.  
  1072.     // Build list of input devices
  1073.     //
  1074.     string $devices[] = `pluginInfo -query -device $name`;
  1075.     if ( size( $devices ) > 0 ) {
  1076.         if ( $featureStr != "" ) {
  1077.             $featureStr = $featureStr + "\n\n";
  1078.             if(`about -mac`){
  1079.                     $numHtCount += 2;
  1080.             }
  1081.         }
  1082.         $featureStr = $featureStr + "  Input Devices:\n";
  1083.         if(`about -mac`){
  1084.                     $numHtCount += 1;
  1085.         }
  1086.         if(`about -mac`)
  1087.             $numHtCount += size( $devices );
  1088.             
  1089.         for ( $device in $devices ) {
  1090.             $featureStr = ( $featureStr + "      " + $device );
  1091.             if ( $device != $devices[ size( $devices ) - 1 ] ) {
  1092.                 $featureStr = $featureStr + "\n";
  1093.             }
  1094.         }
  1095.     }
  1096.  
  1097.     // Build list of drag and drop behaviors
  1098.     //
  1099.     string $behaviors[] = `pluginInfo -query -dragAndDropBehavior $name`;
  1100.     if ( size( $behaviors ) > 0 ) {
  1101.         if ( $featureStr != "" ) {
  1102.             $featureStr = $featureStr + "\n\n";
  1103.         }
  1104.         $featureStr = $featureStr + "  Drag and Drop Behaviors:\n";
  1105.         for ( $behavior in $behaviors ) {
  1106.             $featureStr = ( $featureStr + "      " + $behavior );
  1107.             if ( $behavior != $behaviors[ size( $behaviors ) - 1 ] ) {
  1108.                 $featureStr = $featureStr + "\n";
  1109.             }
  1110.         }
  1111.     }
  1112.  
  1113.     if(`about -mac`) {
  1114.         $numHtCount += 1;
  1115.     }
  1116.  
  1117.     if(`about -mac`) {
  1118.         int    $totalHeight = $numHtCount * 15;
  1119.         
  1120.         textField -edit -text $featureStr  $pluginInfoWinFeatures;
  1121.         textField -edit  -h $totalHeight  $pluginInfoWinFeatures;
  1122.         textField -edit  -ed false  $pluginInfoWinFeatures;
  1123.     } else {
  1124.         text -edit -label $featureStr $pluginInfoWinFeatures;
  1125.     }
  1126.  
  1127.     showWindow $winName;
  1128. }
  1129.  
  1130. global proc pluginWin()  
  1131. //
  1132. //  Procedure Name:
  1133. //      pluginWin
  1134. //
  1135. //  Description:
  1136. //      opens up a window which allows the user to load/unload plugins.
  1137. //      re-scans when called with an open window
  1138. //
  1139. //  Return Value:
  1140. //      None
  1141. //    
  1142. {   
  1143.     global int    $isPluginPathVerified;
  1144.     global string $verifiedPluginPath[];
  1145.     global string $pluginManagerList[];
  1146.  
  1147.     global string $pluginWindowName = "pluginManagerWindow";
  1148.     global string $pluginWinParentWidget;
  1149.  
  1150.     global int      $pluginWinCallbackInstalled = false;
  1151.  
  1152.     string $browseBtn;
  1153.  
  1154.     if (!`window -exists $pluginWindowName`) { 
  1155.         // We have to build the window from scratch, so we will rescan
  1156.         // the directories
  1157.         //
  1158.         resetGlobals;
  1159.  
  1160.         // Create the UI
  1161.         //
  1162.         if(`about -mac`) {
  1163.             window -t "Plug-in Manager" -in "Plug-ins"
  1164.             -menuBar true
  1165.             -retain -wh 450 411 $pluginWindowName;
  1166.         } else {
  1167.         window -t "Plug-in Manager" -in "Plug-ins"
  1168.             -menuBar true
  1169.             -retain -wh 384 411 $pluginWindowName;
  1170.         }
  1171.         menu -label "Help" -helpMenu true;
  1172.             menuItem -label "Help on Plug-in Manager..."
  1173.                 -enableCommandRepeat false
  1174.                 -command "showHelp PluginWindow";
  1175.             
  1176.         // This form layout becomes the default layout for the window
  1177.         //
  1178.         formLayout windowLyt; 
  1179.             tabLayout -cr true -scr true -tv false scrollLyt; 
  1180.                 // The following layout will get deleted a rebuilt if new
  1181.                 // paths or plugins are loaded
  1182.                 //
  1183.                 $pluginWinParentWidget = `columnLayout -adj true parentLyt`;
  1184.                 setParent ..; 
  1185.             setParent ..;
  1186.             $browseBtn = `button -l "Browse" browseBtn`; 
  1187.             $closeBtn = `button -l "Close" closeBtn`; 
  1188.  
  1189.         // Arrange controls in the form
  1190.         //
  1191.         // Attach button 
  1192.         formLayout -e
  1193.             -af $browseBtn "left" 5
  1194.             -ap $browseBtn "right" 3 50 
  1195.             -af $browseBtn "bottom" 5
  1196.             -an $browseBtn "top"
  1197.  
  1198.             -ap $closeBtn "left" 2 50
  1199.             -af $closeBtn "right" 5
  1200.             -af $closeBtn "bottom" 5
  1201.             -an $closeBtn "top"
  1202.             windowLyt;
  1203.  
  1204.         // Attach scroll layout 
  1205.         formLayout -e 
  1206.             -af scrollLyt "top" 0 
  1207.             -af scrollLyt "left" 0 
  1208.             -af scrollLyt "right" 0 
  1209.             -ac scrollLyt "bottom" 5 $browseBtn 
  1210.             windowLyt;
  1211.  
  1212.         button -edit -command "browsePlugin" $browseBtn;
  1213.         button -edit -command "window -e -vis 0 pluginManagerWindow" $closeBtn;
  1214.  
  1215.         setParent ..;
  1216.  
  1217.         // Tell updatePluginWin the check path and build UI
  1218.         //
  1219.         $isPluginPathVerified = 0;
  1220.  
  1221.         // Add a callback to the plugin database so that the window gets
  1222.         // updated
  1223.         //
  1224.         if ( !$pluginWinCallbackInstalled ) {
  1225.             pluginInfo -changedCommand "updatePluginWin();";
  1226.             $pluginWinCallbackInstalled = true;
  1227.         }
  1228.  
  1229.         updatePluginWin();
  1230.     }
  1231.     else
  1232.         updatePluginWin();
  1233.     showWindow $pluginWindowName;
  1234.  
  1235. global proc unloadPluginWithCheck( string $path )
  1236. //
  1237. //  Description:
  1238. //      unload the plugin, or warn if it is being used
  1239. //
  1240.     global string $pluginWindowName;
  1241.     if ( `pluginInfo -query -unloadOk $path` ) {
  1242.         waitCursor -state on;
  1243.         unloadPlugin `pluginInfo -query -name $path`; 
  1244.         waitCursor -state off;
  1245.     } else {
  1246.         string $serviceList[] = `pluginInfo -query -serviceDescriptions $path`;
  1247.         string $services = "";
  1248.         for ( $service in $serviceList  ){
  1249.             $services = ( $services + "- " + $service + "\n" );
  1250.         }
  1251.         string $pluginName = `pluginInfo -query -name $path`;
  1252.         int $isUnlimitedPlugin = false;
  1253.         string $result;
  1254.         if(!strcmp($pluginName,"Fur") || !strcmp($pluginName,"CpClothPlugin") || !strcmp($pluginName,"mayalive"))
  1255.         {
  1256.             $isUnlimitedPlugin = true;
  1257.             $result = `confirmDialog -ma left -title "Plug-in In Use Warning"
  1258.             -message ( "Services provided by this plug-in are\n" + 
  1259.                        "currently in use.\n\n" +
  1260.                        "Forcefully unloading this plug-in opens\n" +
  1261.                        "the \"File->Save Scene As...\" dialog box to save this scene\n"+
  1262.                        "and creates a new empty scene.\n\n"  +
  1263.                           "The following services are in use:\n" + $services ) 
  1264.             -button "Force" -button "Cancel" -defaultButton "Cancel"
  1265.             -cancelButton "Cancel" -dismissString "Cancel"
  1266.             -parent $pluginWindowName`;
  1267.         }
  1268.         else
  1269.         {
  1270.             $result = `confirmDialog -ma left -title "Plug-in In Use Warning"
  1271.                 -message ( "Services provided by this plug-in are\n" + 
  1272.                            "currently in use.\n\n" +
  1273.                            "Unloading this plug-in may cause problems\n" +
  1274.                            "with your scene.  To unload this plug-in\n" +
  1275.                            "safely, remove all objects that reference\n" +
  1276.                            "the plug-in and flush the undo queue either\n" +
  1277.                            "with \"file -new\" or the \"flushUndo\" command.\n\n" +
  1278.                            "The following services are in use:\n" + $services ) 
  1279.                 -button "Force" -button "Cancel" -defaultButton "Cancel"
  1280.                 -cancelButton "Cancel" -dismissString "Cancel"
  1281.                 -parent $pluginWindowName`;
  1282.         }
  1283.         if ( $result == "Force" ) {
  1284.             if( $isUnlimitedPlugin == true)
  1285.             {
  1286.                 SaveSceneAs;
  1287.                 waitCursor -state on;
  1288.                 if ( !strcmp($pluginName,"mayalive") ) {
  1289.                     global int $liveUnloading;
  1290.                     $liveUnloading = 1;
  1291.                     mlResetAllDeletable;
  1292.                     file -f -new;
  1293.                      evalDeferred -lp "unloadPlugin -f mayalive";
  1294.                 }
  1295.                 else {
  1296.                     file -f -new;
  1297.                     unloadPlugin -force `pluginInfo -query -name $path`;
  1298.                 }       
  1299.                 waitCursor -state off;            
  1300.             }
  1301.             else
  1302.             {
  1303.                 waitCursor -state on;
  1304.                 unloadPlugin -force `pluginInfo -query -name $path`;
  1305.                 waitCursor -state off;
  1306.             }
  1307.         }
  1308.         else {
  1309.             // This will turn the check box back on
  1310.             updatePluginWin();
  1311.         }
  1312.     }
  1313. }
  1314.